package cn.iocoder.yudao.module.crm.service.tasktype;

import cn.iocoder.yudao.module.crm.controller.admin.tasktype.vo.tasktypeassignee.TaskTypeAssigneeDetail;
import cn.iocoder.yudao.module.crm.controller.admin.tasktype.vo.tasktypecontent.TaskTypeContentDetail;
import cn.iocoder.yudao.module.crm.dal.dataobject.tasktype.TaskTypeAssigneeDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.tasktype.TaskTypeContentDO;
import cn.iocoder.yudao.module.crm.dal.mysql.tasktype.TaskTypeAssigneeMapper;
import cn.iocoder.yudao.module.crm.dal.mysql.tasktype.TaskTypeContentMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * CRM 任务单类型内容关联 Service 实现类
 *
 * @author 广州氪量
 */
@Service
@Validated
public class TaskTypeContentServiceImpl implements TaskTypeContentService {
    @Resource
    private TaskTypeContentMapper taskTypeContentMapper;
    @Override
    public List<TaskTypeContentDetail> getByTaskTypeId(Long id) {
        List<TaskTypeContentDO> taskTypeContentDOS = taskTypeContentMapper.getByTaskTypeId(id);
        return taskTypeContentDOS.stream()
                .map(TaskTypeContentDetail::toDetail)
                .filter(Objects::nonNull)
                .collect(Collectors.toList());
    }
}